package security;

import java.io.IOException;
import java.security.GeneralSecurityException;
import javax.crypto.SealedObject;

/**
 * Abstract class for sealed objects
 */
public abstract class SealedObj {


    /**
     *
     *
     * @param obj an object
     * @return the object sealed
     * @throws java.io.IOException If an I/O error occurs
     * @throws java.security.GeneralSecurityException If an generic security exception error occurs
     */
    protected abstract SealedObject closedObj(Object obj)
        throws IOException, GeneralSecurityException;


    /**
     *
     * @param sealedObj an sealed object
     * @return
     * @throws java.io.IOException If an I/O error occurs
     * @throws java.lang.ClassNotFoundException
     * @throws java.security.GeneralSecurityException If an generic security exception error occurs
     */
    protected abstract Object unclosedObj(SealedObject sealedObj)
        throws IOException, ClassNotFoundException, GeneralSecurityException;


    /**
     * Returns the object sealed of an specific object
     * 
     * @param obj an object
     * @return the object sealed
     * @throws java.io.IOException If an I/O error occurs
     * @throws java.security.GeneralSecurityException If an generic security exception error occurs
     */
    public SealedObject getSealedObj(Object obj)
        throws IOException, GeneralSecurityException{
		return closedObj(obj);		
	}


    /**
     * Returns the object of an specific object sealed
     * 
     * @param sealedObj an sealed object
     * @return the object 
     * @throws java.io.IOException If an I/O error occurs
     * @throws java.lang.ClassNotFoundException In the class with the specified name could be found.
     * @throws java.security.GeneralSecurityException If an generic security exception error occurs
     */
    public Object getUnsealedObj(SealedObject sealedObj)
        throws IOException,ClassNotFoundException, GeneralSecurityException{
		return unclosedObj(sealedObj);		
	}
	

}
